package com.lyl.module.api.client;


import cn.hutool.json.JSONObject;
import com.dtflys.forest.annotation.Get;
import com.dtflys.forest.annotation.JSONBody;
import com.dtflys.forest.annotation.Post;
import com.lyl.module.constant.AliYunUrlConstant;

/**
 * @author 97134
 * @desc 登录相关
 */
public interface LoginApiClient {

    /**
     * 获取登录二维码
     *
     * @return JSONObject
     */
    @Get(AliYunUrlConstant.GET_LOGIN_QR_CODE)
    JSONObject getLoginQrCode();

    /**
     * 检查二维码的状态
     *
     * @return JSONObject
     */
    @Post(
            url = AliYunUrlConstant.CHECK_QR_CODE_STATE,
            contentType = "application/x-www-form-urlencoded",
            data = {"t=${t}", "ck=${ck}"}
    )
    JSONObject checkQrCodeState();

    /**
     * 获取 code
     *
     * @return JSONObject
     */
    @Post(url = AliYunUrlConstant.TOKEN_LOGIN,
            headers = {
                    "accept: application/json, text/plain, */*",
                    "cookie: ${cookie}"
            },
            contentType = "application/json;charset=UTF-8",
            data = {"{\"token\":\"${token}\"}"}
    )
    JSONObject tokenLogin();

    /**
     * 获取真正的token
     *
     * @param code      code
     * @param loginType normal
     * @param deviceId  deviceId
     * @return jsonObject
     */
    @Post(url = AliYunUrlConstant.GET_TOKEN)
    JSONObject getToken(@JSONBody("code") String code, @JSONBody("loginType") String loginType, @JSONBody("deviceId") String deviceId);

    /**
     * 刷新token
     *
     * @return JSONObject
     */
    @Post(
            url = AliYunUrlConstant.REFRESH_TOKEN,
            contentType = "application/json",
            data = {"{\"refresh_token\":\"${refresh_token}\"}"}
    )
    JSONObject refreshToken();

}
